<template>
  <div class="page-fs">
    <a-input v-model:value="url" />
    <a-input v-model:value="data" />
    <a-select v-model:value="method">
      <a-select-option value="GET">
        GET
      </a-select-option>
      <a-select-option value="POST">
        POST
      </a-select-option>
      <a-select-option value="PUT">
        PUT
      </a-select-option>
      <a-select-option value="DELETE">
        DELETE
      </a-select-option>
    </a-select>
    <a-button @click="submit">
      发起请求
    </a-button>
  </div>
</template>

<script setup>
import axios from "axios";
import { ref } from "vue";

let url = ref('json-server/test')
let method = ref('GET')
let data = ref()
let examplesData = ref('{}')

function submit() {
  let dataType = 'data'
  if (method.value === 'GET') {
    dataType = 'params'
  }
  const config = {
    url: url.value,
    method: method.value
  }
  console.log(config, data.value)
  config[dataType] = JSON.parse(data.value)
  axios.request(config).then(res => {
    console.log(res)
  })
}
</script>

<style scoped>

</style>
